<?php

{$AUTO_GENERATOR_INCLUDE_HEADER_TEMPLATE}

defined('_JEXEC') or die;

class {$AUTO_GENERATOR_COMPONENT|capitalize}Model{$AUTO_GENERATOR_MODEL|capitalize} extends JModelItem {

    public function getTable($name = '{$AUTO_GENERATOR_TABLE_TITLE|capitalize}', $prefix = '{$AUTO_GENERATOR_COMPONENT|capitalize}Table', $options = array()) {
        parent::getTable($name, $prefix, $options);
    }

    public function getItem() {
        $oApp = JFactory::getApplication();
        $iId = $oApp->input->getInt('id', 0);

        $oDb = $this->getDbo();
        $oQuery = $oDb->getQuery(true);
        
        $oQuery->select('*')->from('#__{$AUTO_GENERATOR_SQL_TABLE_NAME}')->where('{$AUTO_GENERATOR_PRIMARY_KEY_FIELD} = ' . $iId);
        
        $oDb->setQuery($oQuery);

        try {
            $oItem = $oDb->loadObject();
        } catch (RuntimeException $oException) {
            JError::raiseWarning(500, $oException->getMessage());
        }
        
        return $oItem;
    }

}

